﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DBLOG.BizTalk.BizTalkExplorerServices.Core;
using Microsoft.BizTalk.Operations;

namespace DBLOG.BizTalk.BizTalkExplorerServices.Explorers
{
    public class MessageExplorer : BizTalkExplorerBase
    {
        public List<BizTalkMessage> GetMessages()
        {
            var messages = from m in this._operations.GetMessages().Cast<BizTalkMessage>().ToList<BizTalkMessage>()
                            select m;

            return messages.ToList<BizTalkMessage>();
        }

        public List<BizTalkMessage> GetSuspendedMessages()
        {
            var suspendedMessages = from m in this._operations.GetMessages().Cast<BizTalkMessage>().ToList<BizTalkMessage>()
                                    where m.MessageStatus == 
                                        MessageStatus.Suspended || 
                                        m.MessageStatus == MessageStatus.SuspendedAll || 
                                        m.MessageStatus == MessageStatus.SuspendedNotResumable
                                    select m;

            return suspendedMessages.ToList<BizTalkMessage>();
        }
    }
}